package org.jivesoftware.smack.util;

import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;

public class ObservableReader extends Reader
{
  Reader wrappedReader = null;
  List<ReaderListener> listeners = new ArrayList();

  public ObservableReader(Reader paramReader)
  {
    this.wrappedReader = paramReader;
  }

  public int read(char[] paramArrayOfChar, int paramInt1, int paramInt2)
    throws IOException
  {
    int i = this.wrappedReader.read(paramArrayOfChar, paramInt1, paramInt2);
    if (i > 0)
    {
      String str = new String(paramArrayOfChar, paramInt1, i);
      ReaderListener[] arrayOfReaderListener = null;
      synchronized (this.listeners)
      {
        arrayOfReaderListener = new ReaderListener[this.listeners.size()];
        this.listeners.toArray(arrayOfReaderListener);
      }
      for (int j = 0; j < arrayOfReaderListener.length; j++)
        arrayOfReaderListener[j].read(str);
    }
    return i;
  }

  public void close()
    throws IOException
  {
    this.wrappedReader.close();
  }

  public int read()
    throws IOException
  {
    return this.wrappedReader.read();
  }

  public int read(char[] paramArrayOfChar)
    throws IOException
  {
    return this.wrappedReader.read(paramArrayOfChar);
  }

  public long skip(long paramLong)
    throws IOException
  {
    return this.wrappedReader.skip(paramLong);
  }

  public boolean ready()
    throws IOException
  {
    return this.wrappedReader.ready();
  }

  public boolean markSupported()
  {
    return this.wrappedReader.markSupported();
  }

  public void mark(int paramInt)
    throws IOException
  {
    this.wrappedReader.mark(paramInt);
  }

  public void reset()
    throws IOException
  {
    this.wrappedReader.reset();
  }

  public void addReaderListener(ReaderListener paramReaderListener)
  {
    if (paramReaderListener == null)
      return;
    synchronized (this.listeners)
    {
      if (!this.listeners.contains(paramReaderListener))
        this.listeners.add(paramReaderListener);
    }
  }

  public void removeReaderListener(ReaderListener paramReaderListener)
  {
    synchronized (this.listeners)
    {
      this.listeners.remove(paramReaderListener);
    }
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     org.jivesoftware.smack.util.ObservableReader
 * JD-Core Version:    0.6.1
 */